home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / DESK / CORE / Desk / h_doc / PopUp < prev    next >
Text File  |  1996-05-21  |  10KB  |  329 lines

  1. /*
  2.  *  ####             #    #     # #
  3.  *  #   #            #    #       #          The FreeWare C library for
  4.  *  #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.  *  #   # #  # #     # #  #     # #  #   ___________________________________
  6.  *  #   # ####  ###  ##   #     # #  #
  7.  *  #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.  *  ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.  *  ________________________________________________________________________
  10.  *
  11.  *  File:    PopUp.h
  12.  *  Author:  Copyright © 1993 Jason Williams
  13.  *  Version: 1.00 (20 May 1993)
  14.  *  Purpose: Low and high-level veneers, typedefs for the PopUp system.
  15.  *
  16.  *  NOTE:
  17.  *  The PopUp system requires support of 2 Wimp message numbers. These
  18.  *  should be integrated into Wimp.h so that you can use:
  19.  *    event->data.message.popupxxx. ...
  20.  *
  21.  *  However, to do this requires permanent wiring of the folowing typedefs
  22.  *  into Wimp.h, which is undesirable if you aren't using PopUps in every
  23.  *  .c file, as it will have a bad effect on compile time/memory use.
  24.  *
  25.  *  Thus, I recommend that you simply #include this file as needed, and
  26.  *  cast the generic message data type from Wimp.h into the specific type
  27.  *  of the message as necessary, e.g.
  28.  *
  29.  *  case Desk_message_POPUPSTATE:
  30.  *  {
  31.  *    Desk_message_popupstate *state;
  32.  *    state = (Desk_message_popupstate *) &event->data.message.data;
  33.  *    switch (state->handle) ...
  34.  */
  35.  
  36.  
  37. #ifndef __Desk_PopUp_h
  38. #define __Desk_PopUp_h
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44.  
  45. #ifndef __Desk_Wimp_h
  46.     #include "Desk.Wimp.h"
  47. #endif
  48.  
  49.  
  50. typedef int Desk_popup_handle;
  51.  
  52.  
  53. /*  The following are defined in Wimp.h
  54.  *    Desk_message_POPUPRQ      0x46D40
  55.  *    Desk_message_POPUPREQUEST 0x46D40
  56.  *    Desk_message_POPUPSTATE   0x46D41
  57.  *    Desk_message_POPUPCLOSED  0x46D42
  58.  */
  59.  
  60. /*
  61.  *  PopUp flag byte: Values of flag bits
  62.  *  Preferably, use the 'all inclusive' values below instead
  63.  */
  64. #define Desk_popup_ISLEAF   (0x01)
  65. #define Desk_popup_ISSTATIC (0x02)
  66.  
  67.  
  68. /*
  69.  *  All-inclusive PopUp flag byte values
  70.  */
  71. #define Desk_popup_STANDALONE (0x00)
  72. #define Desk_popup_MENULEAF   (0x01)
  73. #define Desk_popup_STATIC     (0x02)
  74.  
  75. /*
  76.  *  PopUp-specific data for SWI Desk_PopUp_Open and Desk_Message_PopUpState blocks...
  77.  *  See the PopUp documents for details.
  78.  */
  79.  
  80. typedef struct
  81. {
  82.   int mul, div;
  83.   int minmul, maxmul;
  84.   int mindiv, maxdiv;
  85. } Desk_popup_magnify;
  86.  
  87. typedef struct
  88. {
  89.   char appname[32];
  90.   char purpose[32];
  91.   char author[32];
  92.   char version[32];
  93. } Desk_popup_proginfo;
  94.  
  95. typedef struct
  96. {
  97.   struct
  98.   {
  99.     unsigned int cancel     : 1;    /* Has cancel button / cancel was chosen */
  100.     unsigned int ok         : 1;    /* Has OK button     / OK was chosen     */
  101.     unsigned int reserved   : 6;
  102.     unsigned int userhandle : 24;   /* Put anything you find useful here     */
  103.   } flags;
  104.   char oktext[12];                  /* Text for OK button (if any)           */
  105.   char canceltext[12];              /* Text for cancel button (if any)       */
  106.   char appname[12];                 /* Application name for window titlebar  */
  107.   char message[188];                /* Text message to report to the user    */
  108. } Desk_popup_report;
  109.  
  110. typedef struct
  111. {
  112.   char iconsprite[12];              /* Save As file icon's Iconsprite name   */
  113.   char filename[212];               /* Default text to put into writable icn */
  114. } Desk_popup_saveas;                     /* NOTE a different block is RETURNED... */
  115.  
  116. typedef struct
  117. {
  118.   struct
  119.   {                                /* If Desk_bool_TRUE:           | If Desk_bool_FALSE:         */
  120.     unsigned int wasdragged : 1;   /* File was dragged   | OK was 'pressed'  */
  121.     unsigned int shiftdown  : 1;   /* SHIFT key was down | SHIFT key wasn't  */
  122.     unsigned int reserved   : 30;
  123.   } flags;
  124.  
  125.   int  reserved;
  126.   char filename[212];              /* if (wasdragged) this is a leafname,
  127.                                     * else            this is a full pathname
  128.                                     */
  129. } Desk_popup_saveasreturn;
  130.  
  131. typedef struct
  132. {
  133.   char colour;                     /* Colour 0..15 */
  134. } Desk_popup_wimpcolour;
  135.  
  136.  
  137. typedef struct
  138. {
  139.   unsigned int transparency : 8;
  140.   unsigned int red          : 8;
  141.   unsigned int green        : 8;
  142.   unsigned int blue         : 8;
  143. } Desk_colour_rgb;
  144.  
  145. typedef struct
  146. {
  147.   unsigned int value        : 8;    /* 0..255 */
  148.   unsigned int saturation   : 8;    /* 0..255 */
  149.   unsigned int hue          : 16;   /* 0..359 */
  150. } Desk_colour_hsv;
  151.  
  152. typedef struct
  153. {
  154.   unsigned int key          : 8;
  155.   unsigned int yellow       : 8;
  156.   unsigned int magenta      : 8;
  157.   unsigned int cyan         : 8;
  158. } Desk_colour_cmyk;
  159.  
  160. /*
  161.  *  Colour model numbers. See below for examples of use
  162.  */
  163. #define Desk_popuptc_RGB  0
  164. #define Desk_popuptc_HSV  1
  165. #define Desk_popuptc_CMYK 2
  166.  
  167. /*  Values to OR in to flag value for no transparency, 1 transparency value
  168.  *  ('none' option) and full transparency (256 transparency levels)
  169.  */
  170. #define Desk_popuptc_TRANSPARENT0   0x00000
  171. #define Desk_popuptc_TRANSPARENT1   0x10000
  172. #define Desk_popuptc_TRANSPARENT256 0x20000
  173.  
  174. /*  Examples:
  175.  *  'Draw' style colour:   colourmodel  = Desk_popuptc_RGB | Desk_popuptc_TRANSPARENT1;
  176.  *  Full transparency HSV: colour model = Desk_popuptc_HSV | Desk_popuptc_TRANSPARENT256;
  177.  */
  178.  
  179. typedef struct
  180. {
  181.   int colourmodel;                /* eg: Desk_popuptc_RGB + Desk_popuptc_TRANSPARENCY1 */
  182.   union
  183.   {
  184.     Desk_colour_rgb  rgb;
  185.     Desk_colour_hsv  hsv;
  186.     Desk_colour_cmyk cmyk;
  187.   } colour;
  188.   
  189.   int transparency;                 /* 0..255 */
  190. } Desk_popup_truecolour;
  191.  
  192.  
  193. typedef struct
  194. {
  195.   char       name[12];              /* PopUp type name, eg "SaveAs"          */
  196.   Desk_wimp_point openpos;               /* Position (top left) to open window at */
  197.   char       flags;                 /* menuleaf/standalone/static popup?     */
  198.   char       reserved1, reserved2, reserved3;
  199. } Desk_popup_header;
  200.  
  201.  
  202. typedef union
  203. {
  204.   Desk_popup_magnify    magnify;
  205.   Desk_popup_proginfo   proginfo;
  206.   Desk_popup_report     report;
  207.   Desk_popup_saveas     saveas;
  208.   Desk_popup_wimpcolour wimpcolour;
  209.   Desk_popup_truecolour truecolour;
  210. } Desk_popup_data;                               /* Data to send to popup manager */
  211.  
  212.  
  213. typedef struct
  214. {
  215.   Desk_popup_magnify    magnify;
  216.   Desk_popup_report     report;
  217.   Desk_popup_saveas     saveasreturn;
  218.   Desk_popup_wimpcolour wimpcolour;
  219.   Desk_popup_truecolour truecolour;
  220. } Desk_popup_returndata;                     /* Data recieved in a PopUpState msg */
  221.  
  222.  
  223. typedef struct
  224. {
  225.   Desk_window_handle window;                /* Pass this data directly to         */
  226.   Desk_wimp_point    openpos;               /* Desk_Wimp_CreateSubMenu. Do not pass GO */
  227. } Desk_message_popuprequest;
  228.  
  229.  
  230. typedef struct
  231. {
  232.   Desk_popup_handle     handle;                /* PopUp handle                    */
  233.   char             name[12];              /* PopUp type nam, e.g. "ProgInfo" */
  234.   Desk_popup_returndata data;                  /* Returned state data             */
  235. } Desk_message_popupstate;
  236.  
  237.  
  238. typedef struct
  239. {
  240.   Desk_popup_header header;
  241.   Desk_popup_data   data;
  242. } Desk_popup_block;                                /* Block to send to Desk_PopUp_Open */
  243.  
  244.  
  245.  
  246. /* --------------------------------------------------------------------------
  247.  *  Functions
  248.  * --------------------------------------------------------------------------
  249.  */
  250.  
  251. extern Desk_popup_handle Desk_PopUp_Open(Desk_popup_block *params);
  252.   /*
  253.    *  Straight SWI veneer for Desk_PopUp_Open swi.
  254.    *  (You shouldn't have to call this function - use PopUpShowXXXX, below)
  255.    */
  256.  
  257.  
  258. extern void Desk_PopUp_Close(Desk_popup_handle handle);
  259.   /*
  260.    *  Straight SWI veneer for Desk_PopUp_Close swi.
  261.    *  This will close any PopUp, given the handle as returned by other
  262.    *  PopUp calls (Desk_PopUp_Open, Desk_PopUp_Show)
  263.    *  Note that this is only necessary for STATIC PopUps, and that illegal
  264.    *  calls (popup isn't open, etc) will be ignored.
  265.    */
  266.  
  267.  
  268. extern Desk_popup_handle Desk_PopUp_ShowMenuLeaf(char *name, Desk_popup_data *definition,
  269.                                        Desk_message_menuwarn *msg);
  270.  /*
  271.   *  Higher level interface to Desk_PopUp_Open, which will show a MENU-LEAF PopUp
  272.   *  given the PopUp type name and popup-specific data, plus the "menuwarn"
  273.   *  message that induced your desire to open the PopUp in the first place.
  274.   *
  275.   *  'name'       is the PopUp type name (e.g. "FontSelect")
  276.   *  'definition' is the popup-specific description.
  277.   *
  278.   *  Hypothetical example of use:
  279.   *  case Desk_message_MENUWARN:
  280.   *    switch(event->data.message.data.menuwarn.selection[0])
  281.   *    {
  282.   *      case 3: |* Save => menu item *|
  283.   *      {
  284.   *        Desk_popup_data pud;
  285.   *
  286.   *        strcpy(pud.saveas.iconsprite, "Desk_file_aff");   |* iconsprite name   *|
  287.   *        strcpy(pud.saveas.filename, "DrawFile");     |* Default file name *|
  288.   *        Desk_PopUp_ShowMenuLeaf("SaveAs", &pud,
  289.   *                            &event->data.message.datamenuwarn);
  290.   */
  291.  
  292.  
  293. extern Desk_popup_handle Desk_PopUp_ShowPtr(char *name, Desk_bool isstatic,
  294.                                   Desk_popup_data *definition);
  295.  /*
  296.   *  Higher level interface to Desk_PopUp_Open, which will open a STANDALONE MENU
  297.   *  or STATIC PopUp by filling in the position to open at (over the pointer)
  298.   *  and other header data for you, and open the PopUp as defined by the
  299.   *  passed in "Desk_popup_data" block.
  300.   *
  301.   *  'name'       is the PopUp type name (e.g. "FontSelect")
  302.   *  'isstatic'   indicates if the PopUp should be a static or menu PopUp.
  303.   *  'definition' is the popup-specific description.
  304.   *
  305.   *  Rather than calling ShowPtr directly, use the macros that follow...
  306.   */
  307.  
  308.  
  309. #define Desk_PopUp_ShowStandalone(N, D) Desk_PopUp_ShowPtr(N, 0, D)
  310. /*
  311.  *  These macros simply make Desk_PopUp_ShowPtr nicer to use without causing more
  312.  *  code bulk. They are used to show a standalone-menu or a static (permanent
  313.  *  window) PopUp respectively. Prototypes:
  314.  */
  315.  
  316. #define Desk_PopUp_ShowStatic(N, D) Desk_PopUp_ShowPtr(N, 1, D)
  317. /*
  318.  *  These macros simply make Desk_PopUp_ShowPtr nicer to use without causing more
  319.  *  code bulk. They are used to show a standalone-menu or a static (permanent
  320.  *  window) PopUp respectively. Prototypes:
  321.  */
  322.  
  323. #ifdef __cplusplus
  324. }
  325. #endif
  326.   
  327.  
  328. #endif
  329.